import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class Main {
    public static void main(String[] args) {
        //LinkedList
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        for (Integer x: list){
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("=========");
        ListIterator<Integer> it = list.listIterator();//遍历打印（迭代器打印---正向遍历）
        while (it.hasNext()){
            System.out.print(it.next()+" ");
        }
        System.out.println();

        ListIterator<Integer> it2 = list.listIterator(list.size());//倒着向前打印（使用反向迭代器---反向遍历）
        while (it2.hasPrevious()){
            System.out.println(it2.previous()+" ");
        }
        System.out.println();
    }
}